package com.company.gas.controller;


import com.company.gas.pojo.Install;
import com.company.gas.service.IInstallService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/Install")
@Api(tags = "报装管理相关接口")
public class InstallController {
    @Autowired
    private IInstallService iInstallService;

    //查询全部报装信息
    @GetMapping("/queryInstallList")
    @ApiOperation("查询全部报装信息")
    public List<Install> queryInstallList(){
        List<Install> installList = iInstallService.queryInstallList();
        return installList;
    }

    //查询指定编号对应报装信息
    @GetMapping("/queryInstallById")
    @ApiOperation("查询指定ID报装信息")
    public Install queryInstallById(@RequestParam(value = "报装编号") String istId){
        Install install = iInstallService.queryInstallById(istId);
        System.out.println(install);
        return install;
    }

    //添加一个报装申请
    @GetMapping("/addInstall")
    @ApiOperation("添加一个报装申请")
    public String addInstall(@RequestParam(value = "报装编号") String istId, @RequestParam(value = "报装进程") String istDes,
                             @RequestParam(value = "报装信息") String istPro,
                             @RequestParam(value = "报装时间") Date istTime, @RequestParam(value = "标识符") Integer flag,
                             @RequestParam(value = "创建时间") Date createTime, @RequestParam(value = "创建人") String createBy,
                             @RequestParam(value = "修改时间") Date modifyTime, @RequestParam(value = "修改人") String modifyBy,
                             @RequestParam(value = "报装客户ID") String cusId){
        int isAddInstall = iInstallService.addInstall(istId,istDes,istPro,istTime,flag,createTime,createBy,modifyTime,modifyBy,cusId);
        if(isAddInstall == 1){
            return "add success";
        }else {
            return "add fail";
        }
    }

    //修改一个报装信息
    @GetMapping("/updateInstall")
    @ApiOperation("修改一个报装信息")
    public String updateInstall(@RequestParam(value = "报装进程") String istDes,
                                @RequestParam(value = "报装信息") String istPro,
                                @RequestParam(value = "报装时间") Date istTime,
                                @RequestParam(value = "修改时间") Date modifyTime, @RequestParam(value = "修改人") String modifyBy,
                                @RequestParam(value = "报装客户ID") String cusId){
        int isUpdateInstall = iInstallService.updateInstall(istDes,istPro,istTime,modifyTime,modifyBy,cusId);
        if(isUpdateInstall == 1){
            return "update success";
        }else {
            return "update fail";
        }
    }

    //删除指定编号报装信息
    @GetMapping("/deleteInstall")
    @ApiOperation("删除指定编号报装信息")
    public String deleteInstall(@RequestParam(value = "报装编号") String istId){
        int isDeleteInstall = iInstallService.deleteInstall(istId);
        if(isDeleteInstall == 1){
            return "delete success";
        }else {
            return "delete fail";
        }
    }
}
